<?php
namespace app\common\model;
use think\Model;
use think\model\concern\SoftDelete;

class Subscribe extends Model
{
	use SoftDelete;
	protected $defaultSoftDelete = 0;

	public function scopeNwhere($query,$param)
	{
		if(!empty($param['user_id'])){
			$where[] = ['user_id', '=', $param['user_id']];
		}
		if(!empty($param['cate_id'])){
			$where[] = ['cate_id','=',$param['cate_id']];
		}
		if(isset($where)){
			$query->where($where);
		}
	}
	
	public function user()
	{
		return $this->belongsTo('user');
	}

	public function cate()
	{
		return $this->belongsTo('cate');
	}
}